package me.aip.mov.controller;


import me.aip.mov.annotation.GlobalResult;
import me.aip.mov.annotation.PassToken;
import me.aip.mov.controller.vo.TypeCate;
import me.aip.mov.entity.Type;
import me.aip.mov.service.ITypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author aip9105
 * @since 2022-01-27
 */
@RestController
@GlobalResult
@RequestMapping("/type")
@PassToken
public class TypeController {

    @Autowired
    ITypeService iTypeService;

    @GetMapping("/labels")
    public List<Type> findLabels(){
        return iTypeService.findLabels();
    }

    @GetMapping("/types")
    @Cacheable(cacheNames="findCarousel",key="'typePid='+#typePid")
    public List<Type> findTypes(Integer typePid){
        return iTypeService.findTypes(typePid);
    }

    @GetMapping("/cates")
    public List<TypeCate> findCates(){
        return iTypeService.findCates();
    }
}
